﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RedDragon.Common.Infrastructure.Interface
{
    public interface IBaseRepository<T> where T : class ,new()
    {
        /// <summary>
        /// 获取所有数据
        /// </summary>
        /// <returns>所有数据</returns>
        Task<ISugarQueryable<T>> GetAll();

        /// <summary>
        /// 没有异步获取所有数据
        /// </summary>
        /// <returns></returns>
        List<T> Query();

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="eneity">实体</param>
        /// <returns></returns>
        Task<int> Add(T entity);

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="eneity">实体</param>
        /// <returns></returns>
        Task<int> Update(T entity);

        /// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="entities">实体</param>
        /// <returns></returns>
        int AddRange(List<T> entities);

        /// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="entities">实体</param>
        /// <returns></returns>
        int UpdRange(List<T> entities);
    }
}
